<?php
#[在线客服]
$sysnav = "other";

#[判断权限]
if($_SESSION["admin"]["typer"] != "system" && !$QG_AP["online"])
{
	Error("对不起，您没有权限操作当前功能",$mainlink."?file=index");
}
if($sysAct == "view")
{
	$lead_title = "编辑在线客服";
	$rs = $DB->qgGetOne("SELECT * FROM ".$prefix."online WHERE id='".$id."'");
	$rsd = $DB->qgGetOne("SELECT * FROM ".$prefix."upfiles WHERE id='".$rs["thumb"]."'");	#[缩略图]
}
elseif($sysAct == "viewok")
{
	$id = intval($id);
	$type = $STR->safe($type);
	$name = $STR->safe($name);
	$name_en = $STR->safe($name_en);
	$cusname = $STR->safe($cusname);
	$cusname_en = $STR->safe($cusname_en);
	$cusname_ft = $STR->safe($cusname_ft);
	$link = $STR->safe($link);
	$thumb = intval($thumb);
	$width = intval($width);
	if(!$id)
	{
		$DB->qgQuery("INSERT INTO ".$prefix."online(type,name,name_en,cusname,cusname_en,cusname_ft,link,thumb,width) VALUES('".$type."','".$name."','".$name_en."','".$cusname."','".$cusname_en."','".$cusname_ft."','".$link."','".$thumb."','".$width."')");
		Error("内容创建成功！",$mainlink."?file=online&act=list");
	}
	else
	{
		$DB->qgQuery("UPDATE ".$prefix."online SET type='".$type."',name='".$name."',name_en='".$name_en."',cusname='".$cusname."',cusname_en='".$cusname_en."',cusname_ft='".$cusname_ft."',link='".$link."',thumb='".$thumb."',width='".$width."' WHERE id='".$id."'");
		Error("内容编辑成功！",$mainlink."?file=online&act=list");
	}
}
elseif($sysAct == "style")
{
	$lead_title = "编辑客服样式";
	$rs = $DB->qgGetOne("SELECT * FROM ".$prefix."online WHERE ifonline='1'");
}
elseif($sysAct == "styleok")
{
	$id = intval($id);
	$bgcolor = $STR->safe($bgcolor);
	$hovercolor = $STR->safe($hovercolor);
	
	$check = $DB->qgGetOne("SELECT * FROM ".$prefix."online WHERE ifonline=1");
	if($check)
	{
		$DB->qgQuery("UPDATE ".$prefix."online SET bgcolor='".$bgcolor."',hovercolor='".$hovercolor."',ifonline='1' WHERE id='".$id."'");
		Error("内容编辑成功！",$mainlink."?file=online&act=style");
	}
	else
	{
		$DB->qgQuery("INSERT INTO ".$prefix."online(bgcolor,hovercolor,ifonline) VALUES('".$bgcolor."','".$hovercolor."','1')");
		Error("内容创建成功！",$mainlink."?file=online&act=style");
	}
}
elseif($sysAct == "orderlist")
{
	#[客服列表]
	$onlinelist = $DB->qgGetAll("SELECT * FROM ".$prefix."online WHERE ifonline=0 ORDER BY sortid ASC,id ASC");
}
elseif($sysAct == "orderbyok")
{
	$i=0;
	$listlayer = substr($listlayer,0,(strlen($listlayer)-1));
	//print_r(explode("=",$listlayer));
	
	foreach(explode("=",$listlayer) as $updownlist)
	{
		$i=$i+1;
		$sql="UPDATE ".$prefix."online SET sortid='".$i."' WHERE id='".$updownlist."'";
		$DB->qgQuery($sql);
	}
	Error("排序成功...",$mainlink."?file=online&act=orderlist");
}
elseif($sysact == "delete")
{
	$id = intval($id);
	if(!$id)
	{
		Error("操作非法",$mainlink."?file=online&act=list");
	}
	$DB->qgQuery("DELETE FROM ".$prefix."online WHERE id='".$id."'");
	Error("单页面信息删除成功",$mainlink."?file=online&act=list");
}
else
{
	#[客服列表]
	$rslist = $DB->qgGetAll("SELECT * FROM ".$prefix."online WHERE ifonline=0 ORDER BY sortid ASC,id ASC");
	if(!$rslist)
	{
		$onlinelist = array();
	}
	else
	{
		$i = 1;
		foreach($rslist AS $key=>$value)
		{
			$value["row_index"] = $i;
			$i++;
			$onlinelist[] = $value;
		}
	}
}
Foot("online.qg");
?>